﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BGCOP.CAVTOP.WINFORMS
{
    public partial class frmVisitaProgramadaOK : Form
    {
        public frmVisitaProgramadaOK()
        {
            InitializeComponent();
        }

        private void tVisitaProgramadaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tVisitaProgramadaBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.masterDBACDataSet);

        }

        private void frmVisitaProgramadaOK_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpleado' table. You can move, or remove it, as needed.
            //this.tEmpleadoTableAdapter.Fill(this.masterDBACDataSet.TEmpleado);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpresa' table. You can move, or remove it, as needed.
            this.tEmpresaTableAdapter.Fill(this.masterDBACDataSet.TEmpresa);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TVisitaProgramada' table. You can move, or remove it, as needed.
            this.tVisitaProgramadaTableAdapter.Fill(this.masterDBACDataSet.TVisitaProgramada);

        }

        private void idEmpleadoTextBox_TextChanged(object sender, EventArgs e)
        {
            //
            try
            {
                nombreComboBox.SelectedValue = Convert.ToInt32(idEmpleadoTextBox.Text);
            }
            catch (Exception)
            {
                
                
            }
            
        }

        private void razonSocialComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (razonSocialComboBox.SelectedIndex >= 0)
            {
                idEmpresaTextBox.Text = razonSocialComboBox.SelectedValue.ToString();
                this.tEmpleadoTableAdapter.FillByEmpleadobyEmpresa(this.masterDBACDataSet.TEmpleado, Convert.ToInt32(razonSocialComboBox.SelectedValue));
            }
        }

        private void nombreComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (nombreComboBox.SelectedIndex >= 0)
            {
                idEmpleadoTextBox.Text = nombreComboBox.SelectedValue.ToString();
            }
        }

        private void idEmpresaTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                razonSocialComboBox.SelectedValue = Convert.ToInt32(idEmpleadoTextBox.Text);
            }
            catch (Exception)
            {
                
                
            }
        }
    }
}
